﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using DTcms.Common;

namespace DTcms.BLL
{
    /// <summary>
    ///会员主表
    /// </summary>
    public partial class users_wx
    {
        //private readonly Model.sysconfig sysConfig = new BLL.sysconfig().loadConfig();//获得系统配置信息
        private readonly DAL.users_wx dal;

        public users_wx()
        {
            dal = new DAL.users_wx("dt_");
        }

        #region 基本方法================================
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int id)
        {
            return dal.Exists(id);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.users_wx model)
        {
            return dal.Add(model);
        }

        public int Add(string user_name, string password, string mobile, string avatar, int province_id, int city_id, int district_id, int company_id)
        {
            Model.users_wx model = new Model.users_wx();

          

            int result = dal.Add(model);
            return result;
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.users_wx model)
        {
            return dal.Update(model);
        }
        /// <summary>
        /// 修改一列数据
        /// </summary>
        public int UpdateField(string token, string strValue)
        {
            return dal.UpdateField(token, strValue);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int id)
        {
            return dal.Delete(id);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.users_wx GetModel(int id)
        {
            return dal.GetModel(id);
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
     

        /// <summary>
        /// 获得查询分页数据
        /// </summary>
        public DataSet GetList(int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            return dal.GetList(pageSize, pageIndex, strWhere, filedOrder, out recordCount);
        }
        #endregion

        #region 扩展方法================================

        /// <summary>
        /// 返回信息标题
        /// </summary>
        public string Gettoken(string openid)
        {
            return dal.Gettoken(openid);
        }
        public string WXLogin(string openid) {
            DAL.users udal = new DAL.users("dt_");
            string flag = "";
            Model.users_wx wm = dal.GetModel(openid);
            if (wm != null)
            {
                flag = wm.Token + ";";
                if (wm.User_id > 0) {
                    Model.users u = udal.GetModel(wm.User_id);
                    if (u != null) {
                        flag += u.user_name + ";";
                        flag += u.user_name + ";";
                    }
                }
            }
            else { flag = "E;"; }
            return flag;
        }


        #endregion
    }
}